package cn.cloudplug.friendsrecommend;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import cn.cloudplug.friendsrecommend.R;

public class EditDataActivity extends Activity{
	private EditText et_change;
	private Button bt_submit;
	private String str;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_edit_data);
		setView();
		setListener();
	}
	private void setListener() {
		Intent intent=getIntent();
		str=intent.getStringExtra("title");
		String hint="请输入新的"+str;
		et_change.setHint(hint);
		
	}
	private void setView() {
		// TODO Auto-generated method stub
		ViewGroup vp=(ViewGroup) findViewById(R.id.title);
		et_change=(EditText) findViewById(R.id.et_change);
		bt_submit=(Button) findViewById(R.id.bt_submit);
		vp.findViewById(R.id.iv_home).setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				startActivity(new Intent(EditDataActivity.this, MainActivity.class));
			}
		});
		bt_submit.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent data=new Intent();
				String value=et_change.getText().toString().trim();
				if(TextUtils.isEmpty(value)){
					et_change.setError(str+"不能为空");
					return;
				}
				data.putExtra("value", value);
				setResult(RESULT_OK, data);
				finish();
			}
		});
	}
	


}
